{% extends 'KeioStudyBundle::layout.html.twig' %}

{% block content %}
    <h1>Package</h1>
	<h4>Tên package:</h4>
	{{ entity.name }}
	<h4>Mô tả</h4>
	{{ entity.description }}

	<h3>Các bài đã thuộc package</h3>
	{% for bh in baihocY %}
		<p>Bài học: {{ bh.baihoc }} ({{ bh.monhoc }})
	{% endfor %}

	<h3>Các bài chưa thuộc package</h3>
	<form name="name_for_enable_submit" action="{{ path('keio_package_addbaihoctopackage', {'package_id': entity.id}) }}" method="POST">
		{% for bh in baihocN %}
			<div id="addbaihoctopackage">
				<br><input type="checkbox" name="baihoc[]" value="{{ bh.id }}" onchange="checkform()">
				{{ bh.baihoc }} ({{ bh.monhoc }})
			</div>
		{% endfor %}
		<br><input id="submitbutton" type="submit" disabled="disabled" value="Add"><br>
	</form>

<ul class="record_actions">
    <li>
        <a href="{{ path('keio_package') }}">
            Back to the list
        </a>
    </li>
</ul>
{% endblock %}



{% block morejavascripts %}
		<script type="text/javascript" language="javascript">
		    function checkform()
		    {
		    	var f = document.forms["name_for_enable_submit"].elements;
		    	var cansubmit = true;
		        var x = 0;
		        for (var i = 0; i < f.length; i++) {
		        	if (f[i].checked){
		            	x = x + 1;
		            }
		        }
		        if (x == 0) cansubmit = false;
	            document.getElementById('submitbutton').disabled = !cansubmit;
		    }
		</script>
{% endblock %}